﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TeamDev.JQuery.Internals
{
  public class jqAjax
  {
    public jqExpression get(string uri)
    {
      return new jqExpression(string.Format("$.get('{0}')", uri));
    }

    public jqExpression get(string uri, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.get('{0}', \"{1}\")", uri, datatype));
    }

    public jqExpression get(string uri, object data)
    {
      return new jqExpression(string.Format("$.get('{0}',{1})", uri,
                              InternalUtils.ExtractData(data)));
    }

    public jqExpression get(string uri, object data, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.get('{0}',{1},\"{2}\")", uri,
                              InternalUtils.ExtractData(data),
                              datatype));
    }

    public jqExpression get(string uri, object data, jsFunctionBlock eventObjecthandler)
    {
      return new jqExpression(string.Format("$.get('{0}',{1}, {2})", uri,
                              InternalUtils.ExtractData(data),
                              (string)eventObjecthandler));
    }

    public jqExpression get(string uri, object data, jsFunctionBlock eventObjecthandler, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.get('{0}',{1}, {2},\"{3}\")", uri,
                              InternalUtils.ExtractData(data),
                              (string)eventObjecthandler,
                              datatype));
    }

    public jqExpression get(string uri, jsFunctionBlock eventObjecthandler)
    {
      return new jqExpression(string.Format("$.get('{0}',{1}, {2})", uri,
                              (string)eventObjecthandler));
    }

    public jqExpression get(string uri, jsFunctionBlock eventObjecthandler, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.get('{0}',{1}, {2},\"{3}\")", uri,
                              (string)eventObjecthandler, datatype));
    }

    // ---------------

    public jqExpression post(string uri)
    {
      return new jqExpression(string.Format("$.post('{0}')", uri));
    }

    public jqExpression post(string uri, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.post('{0}', \"{1}\")", uri, datatype));
    }

    public jqExpression post(string uri, object data)
    {
      return new jqExpression(string.Format("$.post('{0}',{1})", uri,
                              InternalUtils.ExtractData(data)));
    }

    public jqExpression post(string uri, object data, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.post('{0}',{1},\"{2}\")", uri,
                              InternalUtils.ExtractData(data),
                              datatype));
    }

    public jqExpression post(string uri, object data, jsFunctionBlock eventObjecthandler)
    {
      return new jqExpression(string.Format("$.post('{0}',{1}, {2})", uri,
                              InternalUtils.ExtractData(data),
                              (string)eventObjecthandler));
    }

    public jqExpression post(string uri, object data, jsFunctionBlock eventObjecthandler, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.post('{0}',{1}, {2},\"{3}\")", uri,
                              InternalUtils.ExtractData(data),
                              (string)eventObjecthandler,
                              datatype));
    }

    public jqExpression post(string uri, jsFunctionBlock eventObjecthandler)
    {
      return new jqExpression(string.Format("$.post('{0}',{1}, {2})", uri,
                              (string)eventObjecthandler));
    }

    public jqExpression post(string uri, jsFunctionBlock eventObjecthandler, AjaxDataType datatype)
    {
      return new jqExpression(string.Format("$.post('{0}',{1}, {2},\"{3}\")", uri,
                              (string)eventObjecthandler, datatype));
    }




  }
}




